package 高性能Golang

import (
	"fmt"
	"regexp"
)

var (
	reg = regexp.MustCompile(`use time (\d+)ms`)
)

func main() {
	logl := "redall use time 49ms, sort use time 432ms"
	indexl := reg.FindAllSubmatchIndex([]byte(logl), -1) //-1代表全部
	fmt.Println(indexl)                                  //二维数组[[7 20 16 18] [27 41 36 39]]
	for i := 0; i < len(indexl); i++ {
		row := indexl[i]
		begin := row[2]
		end := row[3]
		fmt.Println(logl[begin:end]) //找到索引，字符串按索引取值
	}
}
